$(function () {
  const countryObj = {
    奥地利: {
      rule: /^AT[A-Za-z0-9]{18}$/,
      placeholder: "AT+18 digits or LT+18 digits",
    },
    保加利亚: {
      rule: /^BG[A-Za-z0-9]{20}$/,
      placeholder: "BG+20 digits  or LT+18 digits",
    },
    波兰: {
      rule: /^PL[A-Za-z0-9]{26}$/,
      placeholder: "PL+26 digits  or LT+18 digits",
    },
    德国: {
      rule: /^DE[A-Za-z0-9]{20}$/,
      placeholder: "DE+20 digits  or LT+18 digits",
    },
    捷克: {
      rule: /^CZ[A-Za-z0-9]{22}$/,
      placeholder: "CZ+22 digits  or LT+18 digits",
    },
    克罗地亚: {
      rule: /^HR[A-Za-z0-9]{19}$/,
      placeholder: "HR+19 digits  or LT+18 digits",
    },
    罗马尼亚: {
      rule: /^RO[A-Za-z0-9]{22}$/,
      placeholder: "RO+22 digits  or LT+18 digits",
    },
    葡萄牙: {
      rule: /^PT[A-Za-z0-9]{23}$/,
      placeholder: "PT+23 digits  or LT+18 digits",
    },
    斯洛伐克: {
      rule: /^SK[A-Za-z0-9]{22}$/,
      placeholder: "SK+22 digits  or LT+18 digits",
    },
    斯洛文尼亚: {
      rule: /^SI[A-Za-z0-9]{17}$/,
      placeholder: "SI+17 digits  or LT+18 digits",
    },
    西班牙: {
      rule: /^ES[A-Za-z0-9]{22}$/,
      placeholder: "ES+22 digits  or LT+18 digits",
    },
    希腊: {
      rule: /^GR[A-Za-z0-9]{25}$/,
      placeholder: "GR+25 digits  or LT+18 digits",
    },
    匈牙利: {
      rule: /^HU[A-Za-z0-9]{26}$/,
      placeholder: "HU+26 digits  or LT+18 digits",
    },
    意大利: {
      rule: /^IT[A-Za-z0-9]{25}$/,
      placeholder: "IT+25 digits  or LT+18 digits",
    },
    立陶宛: {
      rule: /^LT[A-Za-z0-9]{18}$/,
      placeholder: "LT+18 digits  or LT+18 digits",
    },
    拉脱维亚: {
      rule: /^LV[A-Za-z0-9]{19}$/,
      placeholder: "LV+19 digits  or LT+18 digits",
    },
    爱沙尼亚: {
      rule: /^EE[A-Za-z0-9]{18}$/,
      placeholder: "EE+18 digits  or LT+18 digits",
    },
  };
  const app = {
    formValidationConfig: {
      accountInfoForm: {
        rules: {
          'refund-account-number': {
           refundAccountnNumber: true,
            required: true,
          },
          'account-name': {
            required: true,
          },
          'bank-name': {
            required: true,
          },
          'bank-address': {
            required: true,
          },
          'swift-code': {
            required: true,
          },
        },
        messages: {
          'refund-account-number' : {
            required: "The account number is required",
           refundAccountnNumber: "The refund account format is incorrect",
          },
          'account-name': {
            required: "The account name is required",
          },
          'bank-name': {
            required: "The bank name is required",
          },
          'bank-address': {
            required: "The bank address is required",
          },
          'swift-code': {
            required: "The swiftcode is required",
          },
        },
        options: {
          highlight: function (element) {
            // 当字段验证失败时，添加错误样式
            $(element).addClass("input-error");
          },
          unhighlight: function (element) {
            // 当字段验证成功时，移除错误样式
            $(element).removeClass("input-error");
          },
          errorPlacement: function (error, element) {
            // 将错误消息放置在元素后面
            error.insertAfter(element);
          },
          errorClass: "error-font",
        },
      },
      orderFrom: {
        rules: {
          email: {
            required: true,
          },
          order: {
            required: true,
            noChinese: true,
          },
        },
        messages: {
          email: {
            required: "Invalid email",
          },
          order: {
            required: "Please enter the order number",
            noChinese: "Order number cannot contain Chinese characters",
          },
        },
        options: {
          highlight: function (element) {
            // 当字段验证失败时，添加错误样式
            $(element).addClass("input-error");
          },
          unhighlight: function (element) {
            // 当字段验证成功时，移除错误样式
            $(element).removeClass("input-error");
          },
          errorPlacement: function (error, element) {
            // 将错误消息放置在元素后面
            error.insertAfter(element);
          },
          errorClass: "error-font",
        },
      },
    },
    datas: {
      isSecondComplaint: false, // 是否是第二次投诉
      complaintId: null, // 客诉id
      fileName: null,//面单图片链接
      refuseContent: null,//用户的退款级别
      selectedValue: null, // 单选框选择的值
      filePath: null, // 上传的图片
      processingMode: null, // 处理模式值
      orderAddress: null, // 国家
    },
    // 自定义校验规则
    customValidator: {
      //自定义校验规则订单号不能包含中文
      addOrderFromValidatorMethod: function () {
        $.validator.addMethod(
          "noChinese",
          function (value, element) {
            return !/[\u4e00-\u9fa5]+/.test(value);
          },
          "Order number cannot contain Chinese characters"
        );
      },
      addrefundAccountFromValidatorMethod: function () {
        $.validator.addMethod(
          "refundAccountnNumber",
          function (value, element) {
            if (app.datas.orderAddress) {
              return app.datas.orderAddress.rule.test(value.toUpperCase().trim())  || countryObj["立陶宛"].rule.test(value.toUpperCase().trim()) ;
            } else {
             return true;
            }

          },
          "Please enter your account number in the correct format"
        );
      },
    },
    methods: {

      /**
       * 获取订单归属地
       */
      async getOrderCountryAddress() {
        try {
          const id = getURLParameter("id") || null;
          const res = await $axios.post("/autocomplainthandling/getCountryByLogisticCode", {
            logisticCode: $("#order").val().trim(),
            complaintId: id
          });
          const { datas } = res;
          const countryName = datas.data[0].countryName || null;
          if (countryName) {
            app.datas.orderAddress=countryObj[countryName];
            if (app.datas.orderAddress) {
              $('#refund-account-number').attr('placeholder', app.datas.orderAddress.placeholder);
            } else {
              $('#refund-account-number').attr('placeholder','Please enter your account number');
            }
          }
        } catch (error) {
          console.log(error);
        }
      },
      setAccountInputs(account) {
        // 设置输入框的值
        const { accountName, bankNumber, bankName, bankAddress, swiftCode} = account;
        $("#account-name").val(accountName || null);
        $("#refund-account-number").val(bankNumber || null);
        $("#bank-name").val(bankName || null);
        $("#bank-address").val(bankAddress || null);
        $("#swift-code").val(swiftCode || null);
      },
      //退款级别按钮点击事件
      handleConsentClick() {
        // 选择模态框的footer部分，作为事件监听器的挂载点
        $(".modal-footer").on("click", ".btn.btn-success", function (e) {
          e.preventDefault(); // 阻止默认行为
          app.methods.onRefundSubmit();
        });
      },
      // 查询按钮点击事件
      queryBtnClick() {
        const getAuth = throttle(app.methods.authAndOrder, 3000);
        $(".querybtn").on("click", function () {
          getAuth();
        });
      },
      /**
       * 隐藏所有的弹出层
       */
      hideAllmodal() {
        app.modal.complaint.hide();
        app.modal.accountInfo.hide();
        app.modal.refund.hide();
        app.modal.uploadImg.hide();
        app.loading.hide();
        app.modal.yesNoModal.hide();
      },
      /**
       *
       * @param selector
       * @param rules
       * @param messages
       * @param options
       */
      initOrderFromWithValidation: function () {
        /**
         * 邮箱和订单校验表单
         */
        // 添加自定义验证方法
        app.customValidator.addOrderFromValidatorMethod();
        // 初始化表单验证
        app.methods.initFormValidation(
          "#orderFrom",
          app.formValidationConfig.orderFrom.rules,
          app.formValidationConfig.orderFrom.messages,
          app.formValidationConfig.orderFrom.options
        );
      },
      /**
       * 退款账户的校验方法
       */
      initrefundAccountFromWithValidation:function () {
        // 添加自定义验证方法
        app.customValidator.addrefundAccountFromValidatorMethod();
        // 初始化表单验证
         app.methods.initFormValidation(
          "#accountInfoForm",
          app.formValidationConfig.accountInfoForm.rules,
          app.formValidationConfig.accountInfoForm.messages,
          app.formValidationConfig.accountInfoForm.options
        );
      },
      // 绑定账户输入框的 input 事件
       bindAccountNumberValidation:function() {
          const accountNumberInput = $("#refund-account-number");
          // 当输入框内容改变时触发的事件
          accountNumberInput.on('blur', function (event) {
            // 触发验证
            const valid = $("#orderFrom").validate().form();
            if(!valid){
              return;
            }
        });
     },


      /**
       *
       * @param selector 表单的id
       * @param rules    表单验证规则
       * @param messages  表单错误消息
       * @param options   表单的其它配置选项
       */
      initFormValidation: function (selector, rules, messages, options) {
        const validator = $(selector).validate(
          $.extend(true, {}, options, {
            rules: rules,
            messages: messages,
          })
        );
        return validator;
      },
      init: function () {
        app.methods.queryBtnClick();
        app.methods.handleConsentClick();
        initializeFormWithHiddenInputs("#orderFrom");
        app.methods.initOrderFromWithValidation();
        app.methods.initrefundAccountFromWithValidation();
        app.methods.initializeFormWithHiddenInputs();
        app.methods.bindAccountNumberValidation();
        app.modal = {
          uploadImg: generatorModal("uploadImgModal", app.methods.onSelectImgSubmit), // 上传图片 Modal
          complaint: generatorModal("complaintModal", app.methods.onExchangeRequestSubmit), // 投诉内容 Modal
          refund: generatorModal("refundModal", app.methods.onRefundSubmit), // 同意退款 Modal
          accountInfo: generatorModal("accountInfoModal", app.methods.onAccountInformationSubmit), // 账户信息表单 Modal
          yesNoModal: generatorModal("yesNoModal", app.methods.yesNoModalSubmit),
        };
        app.methods.yesNoFormChange()
      },
      /**
       * 监听是否选择框的方法
       */
       yesNoFormChange : function (){
        document.getElementById("yesNoForm").addEventListener("change", function (event) {
          if (event.target.type === "radio" && event.target.name === "optionsRadios") {
            console.log("Selected option:", event.target.value);
            if (event.target.value == 10) {
              $(".cause-box").hide();
            } else {
              $(".cause-box").show();
            }
          }
        });
      } ,
      /**
       * 验证订单和邮箱
       * @returns
       */
      async authAndOrder() {
        const validator = $("#orderFrom").validate();
        const valid = validator.form();
        if (valid) {
          const email = $("#email").val().trim(); // 获取邮箱
          const orderNum = $("#order").val().trim(); // 获取订单
          app.loading.show(); // 显示 loading
          try {
            // 获取国家地址
            await app.methods.getOrderCountryAddress();
            const res = await $axios.post("autocomplainthandling/getEmailByCode", {logisticCode: orderNum, email,});
            const { datas } = res;
            if (datas.code === 1100) {
              // 校验邮箱订单号不匹配弹出上传图片 Modal
              // $("#uploadImgModal .modal-title").html(`${datas.message} Please upload the voucher.`);
              // 非二次投诉直接弹出上传图片框查询
              if (app.datas.isSecondComplaint == false) {
                $("#uploadImgModal .modal-title").html(
                  "<p>Your email address and logistics number do not match.</p>" +
                    "<p>Please provide a photo of the express package you received.</p>" +
                    "<p>The barcode must be clearly visible on the photo.</p>" +
                    "<p>We will contact you by email later.</p>"
                );
                app.modal.uploadImg.show();
              }
            } //210 状态码说明是未通过或者未审核的数据    220 状态码说明是已通过审核的数据重定向url
            else if (datas.code === 1101 || datas.code === 1102 || datas.code === 1104 || datas.code === 1108) {
              //二次投诉直接重定向对应的链接
              app.datas.isSecondComplaint = true;
              app.toast.show(
                datas.data[0].errorMsg || "The network is abnormal. Please try again later"
              );
            } else if (datas.code ===300) {
              // 校验邮箱订单号匹配成功,查询以什么方式处理
              app.datas.isSecondComplaint = false;
              const processingMode= datas.data[0].processingMode;
              let message = '';
              if(processingMode =="150"){
                 message = `<p>Dear customer</p>
                                <p>Regarding the order number you provided, the logistics shows that the order was rejected by the recipient</p>       
                                <p>If you have any questions, please contact the courier who delivered the order to confirm</p>`;

              }else if (processingMode =="170"){
                message = `<p>Dear customer</p>
                                <p>The order number you provided has not been given to the courier for delivery</p>       
                                <p>Sorry, we cannot handle your complaint</p>`;
              }
              app.toast.show(message);

            }
            else if (datas.code === 210 || datas.code === 220 || datas.code === 230) {
              // 校验邮箱订单号匹配成功,查询以什么方式处理
              app.datas.isSecondComplaint = true;
              window.location.href = `${getLinkUrl()}${datas.data[0].complaintId}`;
            } else if (datas.code === 200) {
              // 校验邮箱订单号匹配成功,查询以什么方式处理
              app.methods.getIsSecondComplaint();
            } else {
              app.toast.show(datas.data[0].errorMsg || "The network is abnormal. Please try again later");
            }
            app.loading.hide($(".order-box"));
          } catch (error) {
            console.log(error);
            app.loading.hide($(".order-box"));
            app.toast.show("The network is abnormal. Please try again later");
          }
        }
      },
      /**
       * 查询处理方式的模版
       *
       */
      /*async getOrderType() {
        try {
          const res = await $axios.post("/autocomplainthandling/getProcessingModeByLogisticCode", {
            logisticCode: $("#order").val(),
            email: $("#email").val(),
          });
          const { datas } = res;
          console.log(datas);
          if (datas.code === 200) {
            app.datas.processingMode = datas.data[0].item;
          } else {
            app.methods.hideAllmodal();
            app.toast.show(
              datas.data[0].errorMsg || "The network is abnormal. Please try again later"
            );
          }
        } catch (error) {
          console.log(error);
          app.toast.show("The network is abnormal. Please try again later");
          app.methods.hideAllmodal();
        }
      },*/
      /**
       * 进行是否是二次投诉判断
       *
       */
      async getIsSecondComplaint() {
        try {
          const res = await $axios.post("/autocomplainthandling/getProcessingModeByLogisticCode", {
            logisticCode: $("#order").val().trim(),
            email: $("#email").val().trim(),
          });
          const { datas } = res;
          if (datas.code === 200) {
            let _data = datas.data[0];
            // 保存处理的模式编码
            let processingMode=app.datas.processingMode = _data.item;
            // 第一次投诉
            const firstValues = ["1", "2", "3"];
            const firstIsIncluded = firstValues.includes(_data.item);
            if (firstIsIncluded) {
              app.datas.isSecondComplaint = false;
              app.modal.complaint.show();
            }

            // 二次投诉
            else{
              const values = ["20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "50", "51","52","70","71","72","73","74","75","100"];
              const isIncluded = values.includes(_data.item);
              if (isIncluded) {
                app.datas.isSecondComplaint = true;
                let complaintId = datas.data[0].autoComplaintHandlingItem.complaintId;
                window.location.href = `${getLinkUrl()}${complaintId}`;
              }
            }
          } else {
            app.toast.show("The network is abnormal. Please try again later");
          }
        } catch (error) {
          app.toast.show("The network is abnormal. Please try again later");
        }
      },

      // 订单被改变或者输入回车
      onOrderBlur: function () {
        // 验证接口节流
        // const getAuth = throttle(app.methods.authAndOrder, 3000);
        // $("#orderFrom input").on("blur", getAuth);
        //$("#orderFrom #order").on("input", delayedGetAuth);
        /*$("#orderFrom #order").on("keydown", function (event) {
                    if (event.key === 'Enter' || event.keyCode === 13) {
                        event.preventDefault();
                        delayedGetAuth();
                    }
                });*/
        // 验证接口防抖
        const delayedGetAuth = debounce(app.methods.authAndOrder, 3000);
      },



      /**
       * 根据 ID 获取投诉信息
       */
      async getComplaintById(id) {
        try {
          app.loading.show(); // 显示 loading
          await app.methods.getOrderCountryAddress();
          const res = await $axios.get(`/autocomplainthandling/getcomplaintById/${id}`);
          const { datas } = res;
          if (datas.code === 200) {
            app.loading.hide();
            app.datas.isSecondComplaint = true;
            let _data = datas.data[0];
            let itemCode = (app.datas.processingMode = _data.item);
            let complaintItem = _data.autoComplaintHandlingItem;
            app.datas.complaintId = complaintItem.complaintId;
            $("#complaintId").val(complaintItem.complaintId);
            $("#email").val(complaintItem.email);
            $("#order").val(complaintItem.logisticCode);
            const fieldsToUpdate = {
              "#complainStatusChnDescription": complaintItem.complainStatusChnDescription !== null  ? complaintItem.complainStatusChnDescription.trim() : '',
              "#bankName": complaintItem.bankName !==null ? complaintItem.bankName.trim() : '',
              "#bankNumber": complaintItem.bankNumber !==null ?  complaintItem.bankNumber.trim(): '',
              "#swiftCode": complaintItem.swiftCode !==null ? complaintItem.swiftCode.trim(): '',
              "#accountName":complaintItem.accountName !==null ? complaintItem.accountName.trim(): '',
              "#complaintDescription": complaintItem.complaintDescription !==null ? complaintItem.complaintDescription.trim(): '',
              "#complaintCause": complaintItem.complaintCause !==null ? complaintItem.complaintCause.trim(): '',
              "#refundLevelInfo": complaintItem.refundLevelInfo !==null ? complaintItem.refundLevelInfo.trim(): '',
              "#complainStatusEnDescription" :complaintItem.complainStatusEnDescription !==null ? complaintItem.complainStatusEnDescription.trim(): '',
            };
            updateAndShowFields(fieldsToUpdate);
            //只有是3的才选择了投诉原因
            if(itemCode!=='3'){
              hideBoxForInput('complaintCause')
            }
            $(".btn.querybtn").hide();



           if (itemCode == "20") {
              const message = `<p>Dear customer</p>
                                                    <p>Your complaint has been accepted</p>
                                                     <p>We are contacting the merchant to confirm the solution</p> 
                                                    <p>You can check the progress again after three working days</p>
                                                    <p>Thank you</p>`;
              app.toast.show(message);
              return;
            } else if (itemCode == "21") {
              app.modal.refund.show();
              initializeRefundContent(0);
              app.methods.setAccountInputs(complaintItem);
              return;
            }
            //3.商家自行退款给收件人
            else if (itemCode == "22") {
             hideBoxForInput('complaintDescription')
              app.modal.yesNoModal.show();
              const message = `<p>Dear customer</p><p>This merchant told us that she has arranged a refund for you</p>`;
              showModal("yesNoModal", message);
              return;
            }
            // 快递直接安排退款
            else if (itemCode == "23") {
             hideBoxForInput('complaintDescription')
              const message = `<p>Dear customer</p>
                                <p>Regarding your complaint about this order, Express has taken over the processing and will refund the payment to you.</p>
                                    <p>This situation is usually caused by you complaining directly to the courier or calling the police.</p> 
                                <p>Please confirm the progress of complaint handling with the express delivery company</p>`;

              app.toast.show(message);
              return;
            }
            //3.商家自行安排换货
            else if (itemCode == "24") {
             hideBoxForInput('complaintDescription')
              app.modal.yesNoModal.show();
              const message = `<p>Dear customer</p><p>Regarding your complaint, the merchant said that he has reached an agreement with you and will send you the replacement goods.</p>
                <p>The time limit for re-shipment of goods is generally 7-15 days</p>
                <p>Do you agree with this processing plan?</p>         
                `;
              showModal("yesNoModal", message);
              return;
            }
            //3.收件人取消投诉
            else if (itemCode == "25") {
             hideBoxForInput('complaintDescription')
              app.modal.yesNoModal.show();
              const message = `<p>Dear customer</p><p>Regarding your complaint, the merchant said that they have reached an agreement with you and you have cancelled the complaint about the order.</p>`;
              showModal("yesNoModal", message);
              return;
            }
            //部分退款不取件  从备注字段中获取    退款比例  refundPercentage
            else if (itemCode == "26") {
              console.log(_data);
              debugger
              refuseContents = _data.refundPercentage;
              initializeRefundContent(0);
              app.modal.refund.show();
              $("#currentOperatingState").val("待审核账户信息");
              return;
            }
            //退款中
            else if (itemCode == "27") {
              const message = `<p>Dear customer</p>
                                <p>Regarding your complaint, Finance is currently undergoing a refund process.</p>
                                    <p>Refunds will normally be issued within one to two weeks from the time you provide the refund information.</p> 
                                <p>Please wait patiently</p>`;

              app.toast.show(message);
              return;
            } //已成功退款  从时间字段中获取时间填充  refundTime
            else if (itemCode == "28") {
             hideBoxForInput('complaintDescription')
              app.modal.yesNoModal.show();
              const message = `<p>Dear customer</p>
              <p>Your order refund has been successfully remitted</p>
              <p>Remittance time is: ${_data.refundTime}</p>
              <p>Have you received it?</p>`;
              showModal("yesNoModal", message);
              return;
            }
            //物流未回款暂不退款
            else if (itemCode == "29") {
              const message = `<p>Dear customer</p>
                                <p>Sorry, the refund will be delayed</p>
                                    <p> Because the courier did not give us the money you paid</p>
                                    <p> There are usually two situations that cause this problem:</p> 
                                    <p> 1. Usually the courier will pay us the money within two weeks after the order is successfully delivered. If you file a complaint on the day you receive the package, you may have to wait 2-3 weeks</p> 
                                    <p> 2. Regarding the complaint about this order, you went to the police station or complained to the Consumer Association. In this case, the courier will withhold the payment. If you want to get the payment, you need to cancel the complaint first and tell them to pay us the payment</p> 
                                    <p>  Only then can we refund your money </p> 
                                <p>Thank you</p>`;

              app.toast.show(message);
              return;
            }
            //收件人长时间未回复邮件暂不处理
            else if (itemCode == "30") {
              const message = `<p>Dear customer</p>
                                                    <p>Unfortunately, the deadline for your order complaint has expired</p>
                                                     <p> Generally, normal complaints are made within three months after the order is placed</p>
                                                     <p> Your complaints will no longer be accepted after three months</p> 
                                                     <p>Please understand</p>`;

              app.toast.show(message);
              return;
            }
            //超客诉期不处理
            else if (itemCode == "31") {
              const message = `<p>Dear customer</p>
                                                    <p>Unfortunately, the deadline for your order complaint has expired</p>
                                                     <p> Generally, normal complaints are made within three months after the order is placed</p>
                                                     <p> Your complaints will no longer be accepted after three months</p> 
                                                     <p>Please understand</p>`;

              app.toast.show(message);
              return;
            } // 退款失败 从失败原因字段中获取 填充  refundCause
            else if (itemCode == "32") {
              $("#currentOperatingState").val("待审核账户信息");
              $("#chineseComplaintCause").val( '退款失败重新填写账户信息');
              app.toast.show(`<p>Dear customer</p>
                <p>Unfortunately, your order remittance failed</p>
                <p>The reason is: ${_data.refundCause}</p>
                <p>Please provide the correct refund information again</p>`);
              app.modal.accountInfo.show();
              return;
            }
            //待审核账户信息
           /* else if (itemCode == "70") {
              const message = `<p>Dear customer</p>
                                                    <p>Regarding your complaint, Finance is currently undergoing a refund process.</p>
                                                     <p>Refunds will normally be issued within one to two weeks from the time you provide the refund information.</p>
                                                     <p>Please wait patiently</p>`;

              app.toast.show(message);
              return;
            }*/ else if (itemCode == "70") {
              //待审核账户信息
              const message = `<p>Dear customer</p>
                                     <p>I have started to apply for a refund</p>
                                      <p>Please wait about a week</p> 
                                      <p>I will get back to you with proof of refund</p>
                                     <p>Thank you</p>`;

              app.toast.show(message);
              return;
            } else if (itemCode == "71") {
              //待审核图片
              const message = `<p>Dear customer</p>
                   <p>Your email address and logistics number do not match</p>
                   <p>Please wait for the background to review the express label picture</p> 
                    <p>Please pay attention to the mailbox to check the processing result</p>
                    <p>Thank you</p>`;
              app.toast.show(message);
              return;
            }else if (itemCode == "72" ||itemCode == "73" ||itemCode == "74" ||itemCode == "75") {
              const message = `<p>Dear customer</p>
                                       <p>Your complaint has been accepted</p>
                                       <p>Please wait for the background to review the express label picture</p> 
                                      <p>You can check the progress again after three working days</p>
                                     <p>Thank you</p>`;
              app.toast.show(message);
              return;
            }

            else if (itemCode == "50") {
              //面单未通过审核
              $("#uploadImgModal .modal-title").html(
                "<p>Your delivery photo is invalid. Please upload it again</p>" +
                  "<p>When uploading pictures, please make sure that the delivery label on the package picture is clearly visible</p>"
              );
              app.modal.uploadImg.show();
            } else if (itemCode == "51") {
              //已通过
              app.datas.isSecondComplaint = false;
              app.datas.processingMode=_data.substate
              app.modal.complaint.show();
              $(".btn.querybtn").hide();

              return;
            }
           else if (itemCode == "52") {
             $("#currentOperatingState").val("待审核账户信息");
             //已通过
             app.toast.show(`<p>Dear customer</p>
                <p>The information you filled in when submitting your refund was incorrect</p>
                <p>Please provide the correct refund information again</p>`);
             app.modal.accountInfo.show();
             $(".btn.querybtn").hide();
             return;
           }

            else if (itemCode == "100" || itemCode == "200" ||itemCode == "0") {
              /*app.toast.show("No record");
              return;*/
              const message = `<p>Dear customer</p>
                                                    <p>Your complaint has been accepted</p>
                                                     <p>We are contacting the merchant to confirm the solution</p> 
                                                    <p>You can check the progress again after three working days</p>
                                                    <p>Thank you</p>`;
              app.toast.show(message);
              return;
            }
          } else {
            app.toast.show("No data!");
            app.loading.hide();
          }
        } catch (error) {
          console.log(error);
          app.toast.show("The network is abnormal. Please try again later");
          app.loading.hide();
        }
      },
      handleUploadImg(e) {
        const _file = $(this)[0].files[0];
        const type = _file.name.split(".");

        if (
          type[type.length - 1] !== "jpg" &&
          type[type.length - 1] !== "jpeg" &&
          type[type.length - 1] !== "png"
        ) {
          app.toast.show("Please select image!");
          return false;
        }
        const formData = new FormData();
        formData.append("file", _file); //默认的文件数据名为“Filedata”
        app.loading.show("uploading...");
        $axios
          .post(`/common/sheetImageUpload`, formData)
          .then((response) => {
            console.log(response);
            const _filepath = (app.datas.filePath = response.datas.filePath);
            app.datas.fileName = response.datas.fileName;
            $(".select-img img").css("display", "block").attr("src", exportFile(_filepath));
            app.loading.hide();
          })
          .catch((error) => {
            console.log(error);
            app.toast.show("The network is abnormal. Please try again later");
            app.loading.hide();
          });
      },
      initializeFormWithHiddenInputs(formContainerSelector) {
        // 使用CSS隐藏第三个及之后的div
        $(formContainerSelector).find(".form-item:not(:first-child):not(:nth-child(2))").hide();
        // 监听所有input的值变化
        $(formContainerSelector)
          .find("input")
          .on("input", function () {
            const $this = $(this);
            const $parentDiv = $this.closest(".form-item");
            // 当input的值不为空时显示其父div
            if ($this.val().trim()) {
              $parentDiv.show();
            } else {
              // 当input的值为空时隐藏其父div
              $parentDiv.hide();
            }
          });
      },

      /**
       * 选择退款级别
       * @returns {Promise<void>}
       */
      onRefundSubmit() {
        if (app.datas.refuseContent) {
          $("#refundLevelInfo").val(app.datas.refuseContent);
        }
          app.modal.accountInfo.show();
      },

      /**
       *
       * 获取单选框选中的值
       */
      getYesNoSelectedReason() {
        let selectedValue = $('input[name="optionsRadios"]:checked').val();
        return selectedValue || null;
      },
      /**
       *
       * 获取单选框选中的值
       */
      getSelectedReason() {
        let selectedValue = $('input[name="reason"]:checked').val();
        return selectedValue || null;
      },

      /**
       *  获取单选框选择的lable 中的文本值
       * @returns {*|jQuery|string}
       */
      getSelectedRadioText() {
        let selectedRadio = $(".reason-radio-box input[type=radio]:checked");
        if (selectedRadio.length > 0) {
          let labelText = selectedRadio.closest("label").text().trim();
          console.log(labelText);
          return labelText;
        } else {
          console.log("No radio button is selected.");
          return "";
        }
      },
      /**
       * yesNoModalSubmit
       * @returns {Promise<void>}
       */
      async yesNoModalSubmit() {
        let selectedValue = (app.datas.selectedValue = app.methods.getYesNoSelectedReason());
        let processingMode = app.datas.processingMode;
        if (!selectedValue) {
          app.toast.show("Please select the Yes or No!");
          return;
        }
        const processingModeObj = {
          22: "商家自行退款给收件人",
          24: "商家自行安排换货",
          25: "收件人取消投诉",
          28: "已成功退款",
        };
        if (processingModeObj[processingMode]) {
          //选择是回填信息
          let causeText = $("#cause-text").val().trim();
          if (selectedValue == "10") {
            if (!causeText) {
              causeText = `${processingModeObj[processingMode]}(yes)`;
              $("#chineseComplaintCause").val(`${processingModeObj[processingMode]}(yes)`);
            }
            $("#currentOperatingState").val( `客户已确认${processingModeObj[processingMode]}`);
            $("#complainStatusChnDescription").val("已处理");
            $("#complainStatusEnDescription").val("Processed");
            setComplaintFields(causeText, causeText);
            hideBoxForInput('complaintDescription')
            hideBoxForInput('complaintCause')
            await app.methods.saveSecondaryComplaint(null);
            app.methods.hideAllmodal();
            app.toast.show("Request successful");
            return;
          }
          //选择否回填信息
           if (selectedValue == "11") {
            const causeText = $("#cause-text").val().trim();
            if (!causeText) {
              app.toast.show("Please fill in the reason");
              return;
            }

             $("#complainStatusChnDescription").val("待处理");
             $("#complainStatusEnDescription").val("Waiting process");
             $("#currentOperatingState").val( `客户未确认${processingModeObj[processingMode]}`);
             $("#chineseComplaintCause").val( `${processingModeObj[processingMode]}(no)`);
             $("#complainStatus").val( `${processingModeObj[processingMode]}`);

             setComplaintFields(causeText, `${processingModeObj[processingMode]}(no)`);

            if(processingMode==="28"){
              $("#currentOperatingState").val( `客户未确认${processingModeObj[processingMode]}`);
              $("#complainStatus").val( `${processingModeObj[processingMode]}`);
              await app.methods.saveSecondaryComplaint("Request successful");
              hideBoxForInput('complaintCause')
              return;
            }
             initializeRefundContent(0);
            app.modal.refund.show();


            //app.modal.accountInfo.show();
             hideBoxForInput('complaintDescription')
             hideBoxForInput('complaintCause')
          }
        }
      },
      /**
       * 二次投诉选择原因后保存信息
       * @returns {Promise<void>}
       */
      async saveSecondaryComplaint(msg) {
        try {
          // 获取表单所有数据
          let formData = serializeFormWithDisabled("#orderFrom");
          const jsonData = {};
          $.each(formData, function (index, field) {
            let key = field.name === "order" ? "logisticCode" : field.name;
            jsonData[key] = field.value;
          });
          jsonData.complainStatusChnDescription = $("#complainStatusChnDescription").val();
          jsonData.complainStatusEnDescription = $("#complainStatusEnDescription").val();
          jsonData.complaintCause = $("#complaintCause").val().trim();
          jsonData.complaintDescription = $("#complaintDescription").val().trim();
          const res = await $axios.post(
            "/autocomplainthandling/save/currentusercomplaint",
            jsonData
          );
          const { datas } = res;
          if (datas.code === 200) {
           /* const message = `<p>Dear customer</p>
                                <p>Regarding your complaint about this order, Express has taken over the processing and will refund the payment to you.</p>
                                    <p>This situation is usually caused by you complaining directly to the courier or calling the police.</p> 
                                <p>Please confirm the progress of complaint handling with the express delivery company</p>`;
*/
            // 回填投诉信息到表单
            app.methods.hideAllmodal();
            const fieldsToUpdate = {
              "#complainStatusEnDescription": $("#complainStatusEnDescription").val().trim(),
              "#bankName": $("#bank-name").val().trim(),
              "#bankNumber": $("#refund-account-number").val().trim(),
              "#swiftCode": $("#swift-code").val().trim(),
              "#accountName": $("#account-name").val().trim(),
              "#bankAddress": $("#bank-address").val().trim(),
            };
            updateAndShowFields(fieldsToUpdate);
          } else {
            app.toast.show(datas.message || "The network is abnormal. Please try again later");
          }
          app.methods.hideAllmodal();
        } catch (error) {
          console.log(error);
          app.toast.show("The network is abnormal. Please try again later");
          app.methods.hideAllmodal();
        }
      },


      // 去除空白值
       getTrimmedValue(selector) {
          return $(selector).val().trim() || "";
        },
      /**
       * 提交账号信息 保存账户信息
       * @returns {Promise<void>}
       *
       *
       */
      async onAccountInformationSubmit() {
        debugger
        //验证表单
        const orderFromValid = $("#orderFrom").validate().form();
        const accountInfoFormValid = $("#accountInfoForm").validate().form();
        if(!orderFromValid || !accountInfoFormValid){
          return ;
        }
        try {
          const processingMode = app.datas.processingMode;
          debugger
          //首次投诉
          if (app.datas.isSecondComplaint == false) {
              if (processingMode === "1") {
                $("#currentOperatingState").val("待审核账户信息");

              } else if (processingMode === "2") {
                $("#currentOperatingState").val("待审核账户信息");

              }else if (processingMode === "3") {
                $("#currentOperatingState").val("待审核账户信息");

              }

            // 获取表单所有数据
            let formData = serializeFormWithDisabled("#orderFrom");
            const jsonData = {};
            $.each(formData, function (index, field) {
              let key = field.name === "order" ? "logisticCode" : field.name;
              jsonData[key] = field.value;
            });
            jsonData.bankName = app.methods.getTrimmedValue("#bank-name");
            jsonData.bankNumber = app.methods.getTrimmedValue("#refund-account-number");
            jsonData.swiftCode =app.methods.getTrimmedValue("#swift-code");
            jsonData.accountName = app.methods.getTrimmedValue("#account-name");
            jsonData.bankAddress = app.methods.getTrimmedValue("#bank-address");
            jsonData.complainStatusChnDescription = "待处理";
            jsonData.complainStatusEnDescription = "Waiting process";
              const res = await $axios.post(
                "/autocomplainthandling/save/currentusercomplaint",
                jsonData
              );
              const { datas } = res;
              if (datas.code === 200) {

                // 回填投诉信息到表单
                app.methods.hideAllmodal();
                let reasonText = $("#reason-text").val().trim();
                let lableText = app.methods.getSelectedRadioText();
                setComplaintFields(reasonText, lableText);
                const fieldsToUpdate = {
                  "#bankName": $("#bank-name").val().trim(),
                  "#bankNumber": $("#refund-account-number").val().trim(),
                  "#swiftCode": $("#swift-code").val().trim(),
                  "#accountName": $("#account-name").val().trim(),
                  "#bankAddress": $("#bank-address").val().trim(),
                  "#complaintCause": $("#complaintCause").val().trim(),
                  "#complaintDescription": $("#complaintDescription").val().trim(),
                  "#complainStatusChnDescription": "待处理",
                  "#complainStatusEnDescription": "Waiting process",

                };
                debugger
                updateAndShowFields(fieldsToUpdate);

                let message='';
                if (processingMode === "1"||processingMode==="2"||processingMode==="3") {
                   message = `<p>Dear customer</p>
                                <p>You have applied for a refund</p>
                               <p>Please wait about a week</p> 
                                <p>I will get back to you with proof of refund</p>
                                <p>thank you</p>`;
                }



                app.toast.show(message||"Request successful");

              } else {
                app.toast.show(datas.message || "The network is abnormal. Please try again later");
                app.methods.hideAllmodal();
              }
          }


          //二次投诉
          else if (app.datas.isSecondComplaint == true) {
            const excludedModes = ["22", "24", "26", "28"];
            if (!excludedModes.includes(processingMode)) {
              $("#complainStatus").val("每日新增客诉订单");
            }

            if (processingMode === "21") {
              $("#complainStatus").val("每日新增客诉订单");

              $("#currentOperatingState").val("待审核账户信息");
              //$("#chineseComplaintCause").val(`二次投诉用户申请退款 ${app.datas.refuseContent}`);
            }
            if (processingMode === "26") {
              $("#currentOperatingState").val("待审核账户信息");
             // $("#chineseComplaintCause").val(`部分退款不取件申请退款 ${app.datas.refuseContent}`);
              $("#complaintDescription").val('--');
            }

            let formData = serializeFormWithDisabled("#orderFrom");
            const jsonData = {};
            $.each(formData, function (index, field) {
              let key = field.name === "order" ? "logisticCode" : field.name;
              jsonData[key] = field.value;
            });
            jsonData.refundLevel = app.datas.refundLevel;
            jsonData.complainStatusChnDescription = "待处理";
            jsonData.complainStatusEnDescription = "Waiting process";
            jsonData.complaintCause = $("#complaintCause").val().trim();
            jsonData.complaintDescription = $("#complaintDescription").val().trim();
            jsonData.bankName = $("#bank-name").val().trim() !== "" ? $("#bank-name").val().trim() : "";
            jsonData.bankNumber = $("#refund-account-number").val().trim() !== "" ? $("#refund-account-number").val().trim() : "";
            jsonData.swiftCode = $("#swift-code").val().trim() !== "" ? $("#swift-code").val().trim() : "";
            jsonData.accountName = $("#account-name").val().trim() !== "" ? $("#account-name").val().trim() : "";
            jsonData.bankAddress = $("#bank-address").val().trim() !== "" ? $("#bank-address").val().trim() : "";


            const res = await $axios.post(
              "/autocomplainthandling/save/currentusercomplaint",
              jsonData
            );
            const { datas } = res;
            if (datas.code === 200) {
              clearModals();
              // 回填投诉信息到表单
              app.methods.hideAllmodal();
              let reasonText = $("#complaintDescription").val().trim();
              let lableText = $("#complaintCause").val().trim();
              setComplaintFields(reasonText, lableText);
              const fieldsToUpdate = {
                "#bankName": $("#bank-name").val().trim(),
                "#bankNumber": $("#refund-account-number").val().trim(),
                "#swiftCode": $("#swift-code").val().trim(),
                "#accountName": $("#account-name").val().trim(),
                "#bankAddress": $("#bank-address").val().trim(),
                "#complainStatusEnDescription": "Waiting process"
              };
              updateAndShowFields(fieldsToUpdate);
              app.modal.uploadImg.hide();
              let message='';
              if (processingMode === "21"||processingMode === "24"||processingMode === "26"||processingMode === "32" ||processingMode === "52") {
                message = `<p>Dear customer</p>
                                <p>You have applied for a refund</p>
                               <p>Please wait about a week</p> 
                                <p>I will get back to you with proof of refund</p>
                                <p>thank you</p>`;
              }if (processingMode === "22") {
                message = `<p>Dear customer</p>
                         <p>Your complaint has been accepted</p>
                         <p>We are contacting the merchant to confirm the solution</p> 
                        <p>You can check the progress again after three working days</p>
                        <p>Thank you</p>`;
              }

               if(processingMode=="24"){
                hideBoxForInput('complaintCause')
              } if(processingMode=="26"){
                hideBoxForInput('complaintDescription')
              }
              if(processingMode=="32"){
                hideBoxForInput('complaintCause')
              }


              app.toast.show(message||"Request successful");
            } else {
              app.toast.show(datas.message || "The network is abnormal. Please try again later");
              app.methods.hideAllmodal();
            }
          }
        } catch (error) {
          console.log(error);
          app.toast.show("The network is abnormal. Please try again later");
          app.methods.hideAllmodal();
        }
      },

      /**
       *
       * 投诉原因提交的时候根据不同的选择进行操作
       */
      async  onExchangeRequestSubmit() {

        // 处理模式3直接保存数据并提示三天的处理期限
        let selectedValue = app.datas.selectedValue = app.methods.getSelectedReason();
        if (!selectedValue) {
          app.toast.show("Please select the cause of complaint!");
          return;
        }
        //处理模式
        let processingMode= app.datas.processingMode;
        //选择1.尺寸不合适，想要换货 保存数据并发送邮件
        if (selectedValue == "1" ) {
          $("#chineseComplaintCause").val("尺寸不合适,想要换货");
          $("#complainStatus").val("每日新增客诉订单");
          $("#currentOperatingState").val("尺寸不合适想要换货");
          $("#sendEmailType").val("尺寸不合适想要换货");
          const message = `<p>Dear customer</p>
                                   <p>Your complaint has been accepted</p>
                                   <p>We are contacting the merchant to confirm the solution</p> 
                                   <p>You can check the progress again after three working days</p>
                                   <p>Thank you</p>`;
          await app.methods.saveSelectData(message);
          return;
        }
          //选择2.尺寸不合适，想要退款
        else if (selectedValue == "2") {
            $("#complainStatus").val("每日新增客诉订单");
            $("#chineseComplaintCause").val("尺寸不合适,想要退款");
            $("#currentOperatingState").val("尺寸不合适想要退款");
        }
          //选择3.对收到的产品质量不满意，想要退款
          else if(selectedValue == "3"){
            $("#complainStatus").val("每日新增客诉订单");
            $("#chineseComplaintCause").val("对收到的产品质量不满意,想要退款");
            $("#currentOperatingState").val("对收到的产品质量不满意想要退款");
          }
          //选择4.收到的产品和订购的不一致
          else if(selectedValue == "4"){
            $("#complainStatus").val("每日新增客诉订单");
            $("#chineseComplaintCause").val("收到的产品和订购的不一致");
            $("#currentOperatingState").val("收到的产品和订购的不一致");
          }
        if (processingMode === "1") {
          //弹框百分之100
          initializeRefundContent(2);
          app.modal.refund.show();
          $("#sendEmailType").val("是罗马尼亚且包含客户");
        } else if (processingMode === "2") {
          //弹框百分之50
          initializeRefundContent(0);
          app.modal.refund.show();
          $("#sendEmailType").val("非罗马尼亚但包含客户");
        } else if (processingMode === "3") {
          $("#sendEmailType").val("其他客户");
          const message = `<p>Dear customer</p>
                                   <p>Your complaint has been accepted</p>
                                   <p>We are contacting the merchant to confirm the solution</p> 
                                   <p>You can check the progress again after three working days</p>
                                   <p>Thank you</p>`;
          await app.methods.saveSelectData(message);
          return;
        }
      },

      /**
       * 其他情况的客户保存
       *  选择1.尺寸不合适，想要换货直接保存并发送邮件
       */
      async saveSelectData(msg) {
        try {
          app.loading.show();
          //获取禁用状态的所有表单属性
          let formData = serializeFormWithDisabled("#orderFrom");
          console.log(formData);
          const jsonData = {};
          $.each(formData, function (index, field) {
            let key = field.name === "order" ? "logisticCode" : field.name;
            jsonData[key] = field.value;
          });
          //投诉原因


          jsonData.sendEmailType= $("#sendEmailType").val();
          jsonData.chineseComplaintCause=$("#chineseComplaintCause").val();
          jsonData.currentOperatingState=$("#currentOperatingState").val();
          jsonData.complainStatus=$("#complainStatus").val();
          jsonData.complaintCause = app.methods.getSelectedRadioText();
          // 投诉的客户描述
          jsonData.complaintDescription = $("#reason-text").val().trim();
          //投诉中文处理状态
          jsonData.complainStatusChnDescription = "待处理";
          //投诉英文处理状态
          jsonData.complainStatusEnDescription = "Waiting process";
          const res = await $axios.post("/autocomplainthandling/save/currentusercomplaint", jsonData);
          const { datas } = res;
          if (datas.code === 200) {
            clearModals();
            const message = `<p>Dear customer</p>
                                    <p>Your complaint has been accepted</p>
                                    <p>We are contacting the merchant to confirm the solution</p> 
                                     <p>You can check the progress again after three working days</p>
                                     <p>Thank you</p>`;
            app.toast.show(msg||message);
            // 关闭弹出框保存并回显数据
            let reasonText = $("#reason-text").val().trim();
            let lableText = app.methods.getSelectedRadioText();
            //回显投诉原因
            setComplaintFields(reasonText, lableText);
            const fieldsToUpdate = {
              "#complainStatusEnDescription": $("#complainStatusEnDescription").val() !== null   ? $("#complainStatusEnDescription").val().trim() : '',
            };
            updateAndShowFields(fieldsToUpdate)
          } else if (datas.code === 1000) {
            app.toast.show(datas.data[0].errorMsg || "The network is abnormal. Please try again later");
          } else {
            app.toast.show( "The network is abnormal. Please try again later");
          }
          app.methods.hideAllmodal();
        } catch (error) {
          console.log(error);
          app.toast.show("The network is abnormal. Please try again later");
          app.methods.hideAllmodal();
        }
      },
      /**
       * 监听上传图片提交
       */
      async onSelectImgSubmit() {
        const fileInputVal = $("#upload").val();
        if (!fileInputVal) {
          app.toast.show("Please select image!");
          return;
        }
        try {
          app.loading.show();
          const res = await $axios.post("/autocomplainthandling/save/waitreviewdata", {
            logisticCode: $("#order").val().trim(),
            email: $("#email").val().trim(),
            fileName: app.datas.filePath,
            complainStatusChnDescription: "待处理",
            complainStatusEnDescription: "Waiting process",
            currentOperatingState:"待审核图片",
            chineseComplaintCause :"面单和订单不一致上传审核",
            complainStatus:"每日新增客诉订单"
          });
          const { datas } = res;
          if (datas.code === 200) {
            app.toast.show("Your order information has been submitted successfully,Please wait for background review,We will contact you by email later.");
            app.loading.hide();
            app.modal.uploadImg.hide();
            const fieldsToUpdate = {
              "#complainStatusEnDescription": 'Waiting process',
            };
            updateAndShowFields(fieldsToUpdate);
          } else if (datas.code === 1000) {
            app.toast.show("Data already exists!");
          } else {
            app.toast.show("The network is abnormal. Please try again later");
          }
          app.loading.hide();
          app.modal.uploadImg.hide();
        } catch (error) {
          app.toast.show("The network is abnormal. Please try again later");
          console.log(error);
          app.modal.uploadImg.hide();
          app.loading.hide();
        }
      },
    },
    // 加载层
    loading: {
      show(message = "loading...") {
        $(".load-mask").remove();
        let loadingTemp = `<div class="load-mask">
                            <div>
                                <div class="load"></div>
                                <p class="tips">${message}</p>
                            </div>
                          </div>`;
        $("body").append(loadingTemp);
      },
      hide() {
        $(".load-mask").remove();
      },
    },
    toast: {
      show(message) {
        const toastLiveExample = document.getElementById("liveToast");
        const toast = new bootstrap.Toast(toastLiveExample, {
          autohide: true,
          delay: 5000,
        });
        //$(".toast-body").text(message);
        $(".toast-body").html(message);

        toast.show();
      },
    },
    // 弹出层
    modal: {},
    async main() {
      this.methods.init();
      // app.modal.uploadImg.show();
      const id = getURLParameter("id") || null;
      // 如果 URL 携带 id,则获取绑定的数据并回填至页面
      if (id) {
        app.methods.getComplaintById(id);
      } else {
        // 解密邮箱
        //const email = await decryptEmail(getURLParameter("em"));
        const email = getURLParameter("em");
        $("#email").val(email);
      }
      // 订单失去焦点
      this.methods.onOrderBlur();
      // 上传图片绑定事件
      $("#upload").on("change", app.methods.handleUploadImg);
      //给各个弹出框按钮绑定提交事件
      app.modal.uploadImg.submit();
      app.modal.complaint.submit();
      app.modal.accountInfo.submit();
      app.modal.yesNoModal.submit();
    },
  };
  app.main();
  let refuseContents = ["50%", "70%", "100%"];
  /**
   *
   * @param {Number} index 退款内容索引
   */
  function updateRefundContent(index) {
    app.datas.refuseContent = refuseContents[index];
    debugger

    const message = `<p>Dear customer</p>
                                <p>Considering that the shipping cost caused by the return needs to be borne by you</p>
                                 <p>Do you accept the following solution?</p> 
                                <p>You can keep the goods and do not need to return them</p>
                                 <p>We can apply for a certain refund ratio for you</p>`;
    if(app.datas.refuseContent!="100%"){
      showModal("refundModal", message);
    }if(app.datas.refuseContent=="100%"){
      debugger
      $("#refundModal .modal-body .content").html('');
    }
    let temp = `Agreed refund percentage
         <span style="color: red; font-weight: bold;">${refuseContents[index]}</span>
        <span style="color: black;">?</span>`;
    $("#refundModal .modal-body .content1").html(temp);

  }
  const refuseBtnEl = $("#refundModal .modal-footer .refuseBtn");
  let contentIndex = 0;
  // 第一次弹出内容
  refuseBtnEl.on("click", function () {
    if (contentIndex < refuseContents.length-1) {
      contentIndex++;
      updateRefundContent(contentIndex);
    }
  });
  function initializeRefundContent(initialIndex) {
    // 设置 contentIndex 的初始值并更新内容
    contentIndex = initialIndex;
    updateRefundContent(contentIndex);
  }
});
